Viewport = function(){
	return{
		clock: function(){
			var task = {
				run: function(){
					Ext.fly("clock").update(Ext.Date.format(new Date(), "d/m/Y h:i:s A"));
				},
				interval: 1000
			};
			Ext.TaskManager.start(task);
		},
		initWindow: function(config){
			this.clock();
			new Ext.Viewport({
				id: "viewport",
				layout: "border",
				minWidth: 1000,
				minHeight: 600,
				items: [
			        {
			        	xtype: "container",
			        	contentEl: "header",
						region: "north",
						height: 50,
						border: false,
						cls:'header'
			        },{
			        	region: "center",
			        	margins: "0 5 5 5 ",
			        	layout: {
							type: "vbox",
							align : "stretch",
							pack  : "start"
						},
						autoScroll: true,
						items: config.items
			        },
			        new Ext.tree.Panel({
			        	title: Asg.constants.APPLICATION_TITLE,
			        	region: "west",
			        	margins: "0 0 5 5",
			        	collapsible: true,
						rootVisible: false,
						autoScroll: true,
			        	width: 250,
			        	listeners: {
			        		itemclick: function(tree, record){
			        			if(record && record.get("leaf") === true && !Ext.isEmpty(record.get("itemUrl"))){
			        				if(record.get("newWindow"))
			        					Asg.Window.openWindow(record.get("itemUrl"), record.get("itemUrlParams"));
			        				else
			        					Asg.Window.openSelfWindow(record.get("itemUrl"), record.get("itemUrlParams"));
			        			}
			        		}
			        	},
			        	store: {
			        		fields: [
		        		         {name: "text"}, 
		        		         {name: "leaf"}, 
		        		         {name: "itemUrl"},
		        		         {name: "itemUrlParams"},
		        		         {name: "newWindow"}
	        		         ],
							root: {
								expanded: true,
								text:"",
								children: [
						           {
						        	   text: "REPORTES",
						        	   expanded: true,
						        	   children: [
				        	              {
				        	            	  text: "POLIZAS POR ASEGURADO", 
				        	            	  leaf: true,
				        	            	  itemUrl: "reportes/generate",
				        	            	  itemUrlParams: {report: "POLIZAS POR ASEGURADO", orientation: "H", type: 1},
				        	            	  newWindow: true
			        	            	  },{
				        	            	  text: "PENDIENTES", 
				        	            	  leaf: true,
				        	            	  itemUrl: "reportes/generate",
				        	            	  itemUrlParams: {report: "PENDIENTES", orientation: "H", type: 3},
				        	            	  newWindow: true
			        	            	  },{
				        	            	  text: "RECLAMOS PENDIENTES", 
				        	            	  leaf: true,
				        	            	  itemUrl: "reportes/generate",
				        	            	  itemUrlParams: {report: "RECLAMOS PENDIENTES", orientation: "H", type: 2},
				        	            	  newWindow: true
			        	            	  }
			        	               ]
					        	   }
					            ]
							}
			        	}
			        })
		        ]
			});
		}
	};
}();